Postgresql Function.html
* created: 2026-06-03T13:40
* modified: 2026-06-04T18:16
title
Title
description
Description
Postgresql Function
Reusable piece of code that is stored in the postgresql catalog. This user-defined functions gets dynamically loaded by the posgresql server, enabling the user to extend the core functionality of posgresql.
Syntax
CREATE OR REPLACE FUNCTION function(parameter text) RETURNS void $$
-- snip --
$$ LANGUAGE sql;
CREATE OR REPLACE makes the function declaration idempotent
Types
SQL
Uses LANGUAGE sql with the body containing sql statements.
Procedural
Uses LANGUAGE plpgsql, which stand for: procedural language postgresql. It enables the user to store the output of a statement in variables and run operations using these variables.
Example:
-- TODO